typedef struct 
{
	DataType list[MaxSize];
	int size;
}SeqList;

void ListInitiate(SeqList *L)
{
	L->size = 0;
}

int ListLength(SeqList L)
{
	return L.size;
}

int ListInsert(SeqList *L, int i, DataType x)
{
	int j;
	
	if(L->size >= MaxSize)
	{
		printf("The list is full, not able to insert!");
		return 0;
	}

	else if(i<0 || i>L->size)
	{
		printf("Parameter Error!");
		return 0;
	}

	else 
	{
		for(j=L->size;j>i;j--)
		{
			L->list[j] = L->list[j-1];
		}

		L->list[i] = x;
		L->size ++;
		return 1;

	}
}

int ListDelete(SeqList *L, int i, DataType *x)
{
	int j;
	if(L->size ==0)
	{
		printf("The list is empty, no element to delete!");
		return 0;
	}

	else if(i<0 || i>L->size)
	{
		printf("Parameter Error!");
		return 0;
	}

	else 
	{
		*x = L->list[i];
		for(j =i+1;j<=L->size-1;j++)
		{
			L->list[j-1] = L->list[j];
		}
		L->size --;
	}

	return 1;
}

int ListGet(SeqList L, int i, DataType *x)
{
	if(i<0||i>L.size)
	{
		printf("Parameter Error");
		return 0;
	}

	*x = L.list[i];
	return 1;
}
